home *** CD-ROM | disk | FTP | other *** search
- class disney.rabbitRivalry.Engine extends MovieClip
- {
- var __gameStartTime;
- var __dogePath;
- var __interval;
- var __sounds;
- var viewport_mc;
- var __state;
- var __UI;
- var activeWorld;
- var isPaused;
- var doge_container;
- var isUILocked;
- var __updateUI;
- var mouse;
- var owner;
- var mouseHD_mc;
- var key;
- var __TOTAL_LEVELS = 5;
- var __STARTLEVEL = 1;
- var __DOGE_PATH = "http://atv.disney.go.com/jetix/media/global/scoredisplays/fsd.swf";
- function Engine()
- {
- super();
- }
- function init()
- {
- this.__gameStartTime = getTimer();
- if(_level0.fsd == undefined)
- {
- this.__dogePath = this.__DOGE_PATH;
- }
- else
- {
- this.__dogePath = _level0.fsd;
- }
- this.__interval = new smashing.IntervalEngine(this,"update");
- this.__interval.startFast();
- disney.rabbitRivalry.Sounds.init();
- this.__sounds = disney.rabbitRivalry.Sounds.getInstance();
- this.__sounds.generateSounds(this.viewport_mc);
- disney.rabbitRivalry.GameState.init();
- this.__state = disney.rabbitRivalry.GameState.getInstance();
- this.__state.reset();
- disney.rabbitRivalry.ui.UI.init();
- this.__UI = disney.rabbitRivalry.ui.UI.getInstance();
- this.__UI.linkEngine(this);
- this.__UI.reset();
- disney.rabbitRivalry.Dimensions.init();
- smashing.keithm.Messenger.registerAddress("engine",this);
- smashing.keithm.Viewport.init(this.viewport_mc,2,disney.rabbitRivalry.Dimensions.getInstance());
- var _loc2_ = smashing.keithm.Viewport.getInstance();
- _loc2_.setScrollport(1);
- _loc2_.createGroup({name:"bg",index:0,slots:10,scrollport:true});
- _loc2_.createGroup({name:"trees",index:1,slots:50,reverse:true});
- _loc2_.createGroup({name:"ents",index:2,slots:500});
- _loc2_.createGroup({name:"player",index:3,slots:10});
- _loc2_.createGroup({name:"effect",index:4,slots:500});
- _loc2_.reset();
- this.activeWorld = new disney.rabbitRivalry.World(this);
- this.__initMouse();
- this.__initKey();
- this.pause();
- this.__UI.goScreen("splash");
- this.__sounds.queueSound("yinyangyo");
- this.__sounds.queueSound("splash",true);
- }
- function update(dt)
- {
- if(!this.isPaused)
- {
- this.activeWorld.update(dt);
- }
- this.__UI.update(dt);
- updateAfterEvent();
- }
- function startGame()
- {
- trace("START GAME");
- this.__state.reset();
- this.startLevel();
- this.__sounds.playMusic("game");
- }
- function startLevel()
- {
- this.__UI.goScreen("gameplay");
- this.activeWorld.generate(this.__state.levelNum);
- smashing.keithm.Viewport.getInstance().newView();
- this.activeWorld.start();
- this.unlockUI();
- this.unpause();
- }
- function onEndLevel()
- {
- if(this.__state.levelNum == this.__state.TOTAL_LEVELS)
- {
- this.__sounds.stopMusic();
- this.__UI.goScreen("winGame");
- }
- else
- {
- this.__UI.goScreen("winLevel");
- }
- }
- function onNextLevel()
- {
- this.__state.levelNum = this.__state.levelNum + 1;
- this.__state.removeMiss();
- this.__state.restartState();
- this.__state.toggleRabbit();
- this.startLevel();
- smashing.keithm.Messenger.sendMessage("screen","onNextRabbit");
- }
- function onGameOver()
- {
- this.__UI.goScreen("gameOver");
- }
- function onStartOver()
- {
- this.__UI.goScreen("splash");
- this.__sounds.playMusic("splash");
- this.__state.reset();
- this.clear();
- }
- function onQuit()
- {
- stopAllSounds();
- this.destroy();
- }
- function onHighscore()
- {
- this.pause();
- this.gotoAndStop("highscore");
- System.security.allowDomain("apsc.disney.go.com");
- _level0.eventID = "jetix_yyy_rr";
- _level0.subject = "Yin Yang Yo - Rabbit Rivalry";
- _level0.playerScore = this.__state.score;
- _level0.fsdPlayAgain = mx.utils.Delegate.create(this,this.onStartOver);
- this.doge_container.loadMovie(this.__dogePath);
- }
- function clear()
- {
- this.activeWorld.clear();
- smashing.keithm.Viewport.getInstance().newView();
- }
- function destroy()
- {
- this.__interval.clear();
- this.__clearMouse();
- this.__clearKey();
- }
- function pause()
- {
- this.isPaused = true;
- }
- function unpause()
- {
- this.isPaused = false;
- }
- function lockUI()
- {
- this.isUILocked = true;
- }
- function unlockUI()
- {
- this.isUILocked = false;
- }
- function requestUpdateUI()
- {
- this.__updateUI = true;
- }
- function showHelp()
- {
- this.__UI.goScreen("help");
- }
- function __initMouse()
- {
- this.mouse = {};
- this.mouse.owner = this;
- this.mouse.onMouseUp = function()
- {
- this.owner.mouse_up();
- };
- this.mouse.onMouseDown = function()
- {
- this.owner.mouse_down();
- };
- Mouse.addListener(this.mouse);
- }
- function __clearMouse()
- {
- Mouse.removeListener(this.mouse);
- }
- function mouse_up()
- {
- if(this.isPaused)
- {
- }
- }
- function mouse_down()
- {
- if(!this.isPaused)
- {
- if(this.mouseHD_mc.hitTest(this._xmouse,this._ymouse,true))
- {
- this.activeWorld.onMouseDown();
- }
- }
- }
- function __initKey()
- {
- this.key = {};
- this.key.owner = this;
- this.key.onKeyDown = function()
- {
- this.owner.key_down();
- };
- Key.addListener(this.key);
- }
- function __clearKey()
- {
- Key.removeListener(this.key);
- }
- function key_down()
- {
- if(Key.getCode() == 32)
- {
- }
- }
- function key_up()
- {
- if(!Key.getCode(32))
- {
- }
- }
- function onMessageReceived(message, args)
- {
- this[message](args);
- }
- function get gameStartTime()
- {
- return this.__gameStartTime;
- }
- function isMusicMuted()
- {
- return this.__sounds.muteMusic;
- }
- }
-